package com.zhenzhang.myblog.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class MvcConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
//        registry.addInterceptor(new LoginHandlerInterceptor())
//                .addPathPatterns("/api/**")
//                .excludePathPatterns(
//                        "/api/user/session",
//                        "/api/article/**"
//                );
        // 用这种方式鉴权到后面使用相同的URL但不同的方法的时候，改起来会有点痛苦, 故放弃
    }

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/api/assets/**")
                .addResourceLocations("classpath:/static/assets/");
    }
}
